package com.bootdo.app.config.wechat;

import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * 订单
 * @author Administrator
 * 2017-11-15 14:42:23
 */
@Component
public class WechatMpConfig {

	@Autowired
	private WechatAccountConfig accountConfig;
	
	@Bean
	public WxMpService wxMpService(){
		WxMpService wxMpService = new WxMpServiceImpl();
		wxMpService.setWxMpConfigStorage(wxMpConfigStorage());
		return wxMpService;
	}
	@Bean
	public WxMpConfigStorage wxMpConfigStorage(){
		WxMpInMemoryConfigStorage memoryConfigStorage = new WxMpInMemoryConfigStorage();
		memoryConfigStorage.setAppId(accountConfig.getMpAppId());
		memoryConfigStorage.setSecret(accountConfig.getMpAppSecret());
		return memoryConfigStorage;
	}
}
